import { ref } from 'vue'
import { defineStore } from 'pinia'
import { getCategoryApi } from '@/apis/layout'

export const useCategoryStore = defineStore('category', () => {
  // state里面的数据
  const categoryList = ref([])
  // action里面修改数据的方法（同步与异步）
  const getCategory = async () => {
    const res = await getCategoryApi()
    categoryList.value = res.data.result
  }
  return {
    categoryList,
    getCategory
  }
})
